package com.vr.xuecheng.gateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;

@Configuration
public class SecurityConfig {
    /**
     * 安全拦截配置
     */
    @Bean
    public SecurityWebFilterChain webFluxSecurityFilterChain(ServerHttpSecurity http) throws Exception {
        return http
                .authorizeExchange()
                // 从白名单过来的放行所有请求，校验部分在过滤器中处理
                .pathMatchers("/**").permitAll()
                .anyExchange().authenticated()
                .and()
                .csrf().disable()
                .build();
    }
}
